home *** CD-ROM | disk | FTP | other *** search
/ Chip 2005 June / ccd0605.iso / Software / Freeware / Programare / highlight / highlight-W32GUI-2.2-10b-Setup.exe / {app} / src / htmlgenerator.h < prev    next >
C/C++ Source or Header  |  2005-03-31  |  4KB  |  148 lines

  1. /***************************************************************************
  2.                           htmlgenerator.h  -  description
  3.                              -------------------
  4.     begin                : Wed Nov 28 2001
  5.     copyright            : (C) 2001 by Andre Simon
  6.     email                : andre.simon1@gmx.de
  7.  ***************************************************************************/
  8.  
  9. /***************************************************************************
  10.  *                                                                         *
  11.  *   This program is free software; you can redistribute it and/or modify  *
  12.  *   it under the terms of the GNU General Public License as published by  *
  13.  *   the Free Software Foundation; either version 2 of the License, or     *
  14.  *   (at your option) any later version.                                   *
  15.  *                                                                         *
  16.  ***************************************************************************/
  17.  
  18.  
  19. #ifndef HTMLGENERATOR_H
  20. #define HTMLGENERATOR_H
  21.  
  22. #include <fstream>
  23. #include <iostream>
  24. #include <string>
  25. #include <sstream>
  26.  
  27. #include "codegenerator.h"
  28. #include "version.h"
  29. #include "stylecolour.h"
  30. #include "elementstyle.h"
  31. #include "platform_fs.h"
  32.  
  33. namespace highlight {
  34.  
  35. /**
  36.    \brief This class generates HTML.
  37.  
  38.    It contains information about the resulting document structure (document
  39.    header and footer), the colour system, white space handling and text
  40.    formatting attributes.
  41.  
  42. * @author Andre Simon
  43. */
  44.  
  45. class HtmlGenerator  : public highlight::CodeGenerator
  46.   {
  47.   public:
  48.  
  49.     /** Constructor
  50.      \param colourTheme Name of Colour theme to use
  51.      \param enc encoding name
  52.      \param omitEnc switch to omit encoding information
  53.      \param withAnchors Test if HTML anchors should be attached to line numbers
  54.     */
  55.     HtmlGenerator(const string &colourTheme,
  56.                   const string &enc,
  57.                   bool omitEnc=false,
  58.                   bool withAnchors = false);
  59.  
  60.     HtmlGenerator();
  61.  
  62.     /** Destructor*/
  63.     virtual ~HtmlGenerator() {};
  64.  
  65.     /** insert line number in the beginning of the new line
  66.     */
  67.     virtual void insertLineNumber(bool insertNewLine=true);
  68.  
  69.     /** Print document header
  70.        \param  title Title of the document
  71.     */
  72.     string getHeader(const string &title);
  73.  
  74.     /** Print document body*/
  75.     void printBody();
  76.  
  77.     /** Print document footer*/
  78.     string getFooter();
  79.  
  80.     /** Print style definitions to external file
  81.      \param outFile Path of external style definition
  82.      */
  83.      bool printExternalStyle(const string &outFile);
  84.  
  85.     /** Print index file with all input file names
  86.       \param fileList List of output file names
  87.       \param outPath Output path
  88.     */
  89.      bool printIndexFile(const vector<string> & fileList, const string &outPath);
  90.  
  91.   protected:
  92.  
  93.     /** some strings which are similar in HTML and XHTML*/
  94.     string brTag, hrTag, idAttr, fileSuffix;
  95.  
  96.     /** Output encoding name */
  97.     string encoding;
  98.  
  99.     /** switch to omit encoding name in file header */
  100.     bool omitEncoding;
  101.  
  102.     /** HTML footer */
  103.     string HTML_FOOTER;
  104.  
  105.     /** caches style definition */
  106.     string styleDefinitionCache;
  107.  
  108.     /** \return CSS definition */
  109.     string  getStyleDefinition();
  110.  
  111.     /** \return Content of user defined style file */
  112.     string readUserStyleDef();
  113.  
  114.     /** \param title Dociment title
  115.         \return Start of file header */
  116.     virtual string getHeaderStart(const string &title);
  117.  
  118.   private:
  119.  
  120.     /**  \param styleName Style name
  121.          \return Opening tag of the given style
  122.     */
  123.     string getOpenTag(const string& styleName);
  124.  
  125.     /** \return escaped character*/
  126.     virtual string maskCharacter(unsigned char );
  127.  
  128.     /** test if anchors should be appied to line numbers*/
  129.     bool attachAnchors;
  130.  
  131.     /**\return text formatting attributes in HTML format */
  132.     string  formatStyleAttributes(const string & elemName, const ElementStyle & elem);
  133.  
  134.     /**  \param styleID Style ID
  135.          \return Opening tag of the given style
  136.     */
  137.     string getMatchingOpenTag(unsigned int styleID);
  138.  
  139.     /**  \param styleID Style ID
  140.          \return Closing tag of the given style
  141.     */
  142.     string getMatchingCloseTag(unsigned int styleID);
  143.   };
  144.  
  145. }
  146.  
  147. #endif
  148.